package com.neil.dynamic.gateway.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.cloud.gateway.route.RouteDefinitionLocator;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 *  获取网关的路由信息
 * @ProjectName:
 * @Package:        com.neil.dynamic.gateway.controller
 * @ClassName:      DynamicRouteController
 * @Description:    java类作用描述
 * @Author:         Neil.Zhou
 * @CreateDate:     2019/10/14 16:19
 * @UpdateUser:     Neil.Zhou
 * @UpdateDate:     2019/10/14 16:19
 * @UpdateRemark:   The modified content
 * @Version:        1.0
 * <p>Copyright: Copyright (c) 2019/10/14</p>
 *
 */
@RestController
@RequestMapping("/route")
public class DynamicRouteController {

    @Autowired
    private RouteDefinitionLocator routeDefinitionLocator;

    /**
     * 获取网关所有的路由信息
     * @method
     * @author  作者姓名
     * @version
     * @param
     * @return
     * @exception
     * @date    2019/10/14 16:20
     */
    @RequestMapping("/routes")
    public Flux<RouteDefinition> getRouteDefinitions(){
        return routeDefinitionLocator.getRouteDefinitions();
    }
}
